<template>
  <div style="font-size: 30px; font-weight: bold"><span style="font-size:25px;margin-right:6px">{{adminInfo.name}}</span>,欢迎登录</div>
</template>
<script>
import cookie from "js-cookie";
let Base64 = require("js-base64").Base64;
export default {
  data() {
    return {
      //token 分为3段 头为加密算法 尾部为自签名 中间为数据部分
      token: cookie.get("token").split(".")[1],
      adminInfo: {
        name: "",
        id: "",
        avatar: "",
        exp: "",
      },
    };
  },
  created() {
    this.adminInfo = JSON.parse(Base64.decode(this.token));
  },
  mounted() {
    if (cookie.get("token")) {
      return;
    } else {
      this.$router.replace("/");
    }
  },
};
</script>